package com.atguigu.gulimall.search.controller.web;

import com.atguigu.gulimall.search.dto.SearchDto;
import com.atguigu.gulimall.search.service.SearchService;
import com.atguigu.gulimall.search.vo.SearchResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;


/**
 * @author xin
 */
@Controller
public class SearchController {

    @Autowired
    private SearchService searchService;

    @GetMapping(value = {"/","/index.html"})
    public String index() {
        return "search";
    }

    @GetMapping(value = {"/search.html", "/list.html"})
    public String search(SearchDto searchDto, Model model) {

        SearchResultVo searchList = searchService.search(searchDto);
        model.addAttribute("searchList", searchList);
        return "search";
    }

//    @GetMapping("/list.html")
//    public String list(@RequestBody SearchDto catalog3Id) {
//
//    }

}
